$(function () {
  $.ajax({
    url: "http://chst.vip:1234/api/getbrandtitle",
    success: (res1) => {
      let htm = "";
      $.each(res1.result, (i1, item1) => {
        htm += `
        <li titleId='${item1.brandTitleId}'>
            <span>${item1.brandTitle}<b>▼</b></span>
            <div class='detail${i1}'>
            </div>
        </li>
        `;
        $.ajax({
          url: `http://chst.vip:1234/api/getbrand?brandtitleid=${item1.brandTitleId}`,
          success: (res2) => {
            let htm2 = "";
            $.each(res2.result, (i2, item2) => {
              htm2 += `
            <a href='brand.html?title=${item2.brandName}&amp;brandTitleId=${item2.brandTitleId}'>
              <em>${i2}</em>
              <i>${item2.brandName}</i>
              <p>${item2.brandInfo}</p>
            </a>
            `;
            });
            $(`.detail${i1}`).html(htm2);
          },
        });
      });
      $("ul").html(htm);
      $(".main li div").hide().css("height", "100%");
      $(".main li span").click(function () {
        $(this).next().slideToggle(200).end().children("b").text("▲");
      });
    },
  });
});
